package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author 西门凌兰
 * @version 1.0
 */
@Mapper
public interface OrderDetailMapper {

    /**
     * 批量插入订单明细数据
     * @param orderDetails
     */
    void insertBatch(List<OrderDetail> orderDetails);

    /**
     * 根据订单id查询订单明细
     * @param orderId
     * @return
     */
    @Select("select * from order_detail where order_id = #{orderId}")
    List<OrderDetail> getByOrderId(Long orderId);

    /**
     * 得到销量前十名称
     * @param beginTime
     * @param endTime
     * @return
     */
    List<String> getTop10Name(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 统计销量前十数量
     * @param beginTime
     * @param endTime
     * @return
     */
    List<Integer> getTop10Number(LocalDateTime beginTime, LocalDateTime endTime);
}
